<?php
global $_GPC,$_W;
$weid=intval($_W['uniacid']);
load()->func('tpl');
$opp = 'city_overrule';
$operation=!empty($_GPC['op']) ? $_GPC['op'] : 'display';
if($operation == 'display'){
    $city_overrule=pdo_fetchall("SELECT * FROM ".tablename('bbyscm_card_city_overrule')." WHERE uniacid = '{$_W['uniacid']}' ");
} elseif($operation == 'post') {
    $id=intval($_GPC['id']);
    if(!empty($id)){
        $city_overrule=pdo_fetch("SELECT * FROM ".tablename('bbyscm_card_city_overrule')." WHERE id = '$id'");
    }
    if(checksubmit('submit')){
        $data=array('uniacid'=>$_W['uniacid'], 'days'=>$_GPC['days'], 'coll'=>trim($_GPC['coll']));
        if(!empty($id)){
            pdo_update('bbyscm_card_city_overrule', $data, array('id'=>$id));
        } else {
            pdo_insert('bbyscm_card_city_overrule', $data);
            $id=pdo_insertid();
        }
        message('更新成功！', $this->createWebUrl('city_overrule', array('op'=>'display')), 'success');
    }

} elseif($operation == 'delete') {
    $id=intval($_GPC['id']);
    $category=pdo_fetch("SELECT id FROM ".tablename('bbyscm_card_city_overrule')." WHERE id = '$id'");
    if(empty($category)){
        message('抱歉，不存在或是已经被删除！', $this->createWebUrl('city_overrule', array('op'=>'display')), 'error');
    }
    pdo_delete('bbyscm_card_city_overrule', array('id'=>$id));
    message('删除成功！', $this->createWebUrl('city_overrule', array('op'=>'display')), 'success');
}

include $this->template('web/city_overrule');